//
//  QualificationIntroController.m
//  ATMCash
//
//  Created by zhengchengfeng on 2024/9/7.
//

#import "QualificationIntroController.h"
#import "QualificIntroTableCell.h"

#define kTabCell  @"kTabCell"

@interface QualificationIntroController ()

@property (nonatomic) UIView *headView;

@end

@implementation QualificationIntroController

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"Qualification Introduction";
    
    [self.tableView registerClass:[QualificIntroTableCell class] forCellReuseIdentifier:kTabCell];
    
    UIImage *img = [UIImage imageNamed:@"icon_qualific1"];
    UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, img.size.height - 80)];
    self.headView = headView;
    self.tableView.tableHeaderView = headView;
    
    UIImageView *imgV= [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, img.size.height)];
    [headView addSubview:imgV];
    imgV.image = img;
    
    NSArray *arr = @[
        @{
            @"title":@"We are registered since 2023 in compliance for financing and lending companies of regulations and laws",
            @"iconName":@"icon_qualific3",
        },
        @{
            @"title":@"We value confidentiality and integrity to our customer's information. We are deemed to protect them from any unlawful activity which is in accordance with Republic Act No.9160",
            @"iconName":@"icon_qualific2",
        },
    ];
    self.data = [QualificaIntroModel mj_objectArrayWithKeyValuesArray:arr];
    
    [self.tableView reloadData];
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.data.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    QualificaIntroModel *mm = self.data[indexPath.section];
    return [QualificIntroTableCell getCellHeight:mm];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    QualificIntroTableCell *cell = [tableView dequeueReusableCellWithIdentifier:kTabCell];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.model = self.data[indexPath.section];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 20;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *vv = [[UIView alloc] init];
    return vv;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.0001f;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *vv = [[UIView alloc] init];
    return vv;
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        [tableView sendSubviewToBack:self.headView];
    }
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
